<template>
  <!-- 用户信息 -->
  <div class="yhxx">
    <span>
      <i style="font-family: 800; font-size: 22px" class="el-icon-user"></i>
      用户信息
    </span>
    <el-divider></el-divider>

    <!-- 编辑前 -->
    <div v-if="modificationNameshow1" class="jdzj">
      <table>
        <tbody>
          <tr>
            <td><span>平台名称：</span></td>
            <td
              style="width: 310px; height: 31px; margin-top: 9px; float: left"
            >
              <span style="font-size: 14px">海令云终端管理平台</span>
            </td>
            <td>
              <el-button type="text" @click="modificationName()"
                >修改名称</el-button
              >
            </td>
          </tr>
          <tr>
            <td><span>登录密码：</span></td>
            <td>
              <span style="text-align: center">**********</span>
            </td>
            <td>
              <el-button type="text" @click="modificationpassword()"
                >修改密码</el-button
              >
            </td>
          </tr>
        </tbody>
      </table>
    </div>

    <!-- 编辑中 -->
    <div v-if="modificationNameshow" class="jdzj">
      <table>
        <tbody>
          <tr>
            <td><span>平台名称：</span></td>
            <td style="width: 310px; height: 30px; float: left">
              <!-- <el-input
                style="margin-left: -15px"
                class="input"
                v-model="input"
                placeholder="请输入平台名称"
              >
              </el-input> -->
              <el-input disabled v-model="NameValue"></el-input>
            </td>
            <td>
              <el-button type="text" @click="modificationName1()"
                >✓保存修改</el-button
              >
            </td>
          </tr>
          <tr>
            <td><span>登录密码：</span></td>
            <td>
              <!-- <el-input
                style="margin-left: -15px"
                class="input"
                v-model="input1"
                placeholder="请输入密码"
                show-password
              ></el-input> -->
              <el-input show-password v-model="PasswordValue"></el-input>
            </td>
            <td>
              <el-button
                type="text"
                @click="modificationpassword1(PasswordValue)"
                >✓保存密码</el-button
              >
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</template>
<script>
import Api from "@/api/api";
export default {
  data() {
    return {
      modificationNameshow: false,
      modificationNameshow1: true,
      NameValue: "海令云终端管理平台",
      PasswordValue: "",
      // localSid: localStorage.getItem("sid"),
      localSid: "577688740d9d258b92c61e6b1f5498ff",
    };
  },
  methods: {
    // 修改平台名称

    modificationName1() {
      // this.modificationNameshow = !this.modificationNameshow;
      // this.modificationNameshow1 = !this.modificationNameshow1;
      this.$message({
        type: "error",
        message: "平台名称默认不可修改!",
      });
    },
    modificationName() {
      this.modificationNameshow = !this.modificationNameshow;
      this.modificationNameshow1 = !this.modificationNameshow1;
    },
    // 修改登录密码
    modificationpassword() {
      this.modificationNameshow = !this.modificationNameshow;
      this.modificationNameshow1 = !this.modificationNameshow1;
    },
    async modificationpassword1(row) {
      console.log("row", row);

      if (this.PasswordValue) {
        let result = await Api.set_password({
          params: [
            this.localSid,
            "ui",
            "set_password",
            {
              username: "admin",
              password: this.PasswordValue,
            },
          ],
        });
        if (result.result == null) {
          this.$message({
            showClose: true,
            type: "success",
            message: "设置成功",
          });
        }
        this.modificationNameshow = !this.modificationNameshow;
        this.modificationNameshow1 = !this.modificationNameshow1;
      } else {
        this.$message({
          showClose: true,
          type: "error",
          message: "密码不能为空",
        });
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.yhxx {
  width: 95%;
  height: calc(100vh - 180px);
  margin-left: 40px;
}

::v-deep .el-divider--horizontal {
  margin: 10px 0 0 0;
}
::v-deep .el-input.is-disabled .el-input__inner {
  background-color: #ffffff00;
  line-height: 1px;
}
::v-deep .jdzj {
  align-items: center;
  margin-left: 50px;
  margin-top: 25px;
  width: 80%;

  .el-input__inner {
    border: none;
    outline: none;
    box-shadow: none;
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }
}
.input {
  width: 60%;
}
</style>
